#include "App.h"
#include "ScenePlay.h"

#include "MapManager.h"
#include "ActivityManager.h"

#include "Activity.h"
#include "Character.h"
#include "Tile.h"
#include "Map.h"


Activity::Activity() {
	type_ = NODE_ACTIVITY;
	priority_ = c_priority_defualt;
	turnTime_ = 1.0;
}

Activity::~Activity() {

}

bool Activity::do_act(Node* actor, Node* object) {
	for each(auto act in lstAct_) {
		if (act(actor, object)) {
			return true;
		}
	}
	return false;
}

bool Activity::act_move(Node* actor, Node* object) {
	Character* cha = (Character*)actor;
	Tile* tile = (Tile*)object;
	Tile* tile2 = cha->getTileUnderCha();

	if (!tile->isPassable())
		return false;

	if (tile->getChaOnTile() != NULL)
		return false;

	Tile* curTile = cha->getTileUnderCha();
	curTile->setChaOnTile(NULL);
	tile->setChaOnTile(cha);
	return true;
}

ActivityMove::ActivityMove() {
	this->createNode("activity_move");
	lstAct_.push_back(act_move);
}